//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>
package org.jpgolay.wi;

import java.awt.*;
import java.util.ResourceBundle;
import javax.swing.*;

public class MainGUI extends JFrame {

    public MainGUI() {
        preferencesMI = null;
        setIconImage((new ImageIcon(getClass().getResource("/org/jpgolay/wi/images/logo.gif"))).getImage());
        initComponents();
    }

    private void initComponents() {
        buttonGroup1 = new ButtonGroup();
        mainTB = new JToolBar();
        realEstateB = new JButton();
        realEstateListB = new JButton();
        diaryB = new JButton();
        helpB = new JButton();
        mainSP = new JScrollPane();
        mainDP = new JDesktopPane();
        jMenuBar1 = new JMenuBar();
        file = new JMenu();
        openNew = new JMenu();
        outsider = new JMenu();
        realEstate = new JMenuItem();
        open = new JMenu();
        realEstateMI = new JMenuItem();
        realEstateList = new JMenuItem();
        customerMI = new JMenuItem();
        salesPersonMI = new JMenuItem();
        userMI = new JMenuItem();
        agencyMI = new JMenuItem();
        groupMI = new JMenuItem();
        jSeparator1 = new JSeparator();
        exit = new JMenuItem();
        tools = new JMenu();
        guiM = new JMenu();
        glassRBMI = new JRadioButtonMenuItem();
        defaultRBMI = new JRadioButtonMenuItem();
        bedouinRBMI = new JRadioButtonMenuItem();
        acidRBMI = new JRadioButtonMenuItem();
        metalRBMI = new JRadioButtonMenuItem();
        jSeparator2 = new JSeparator();
        info = new JMenu();
        help = new JMenuItem();
        jSeparator3 = new JSeparator();
        about = new JMenuItem();
        setTitle(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("wi_title"));
        mainTB.setOrientation(1);
        realEstateB.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/wi/images/un_bien.png")));
        realEstateB.setToolTipText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("realestate_card"));
        realEstateB.setBorder(null);
        realEstateB.setBorderPainted(false);
        realEstateB.setMargin(new Insets(2, 2, 2, 2));
        realEstateB.setMaximumSize(new Dimension(25, 25));
        realEstateB.setMinimumSize(new Dimension(25, 25));
        realEstateB.setPreferredSize(new Dimension(25, 25));
        realEstateB.setEnabled(false);
        mainTB.add(realEstateB);
        realEstateListB.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/wi/images/liste_bien.png")));
        realEstateListB.setToolTipText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("realestate_list"));
        realEstateListB.setBorder(null);
        realEstateListB.setMargin(new Insets(2, 2, 2, 2));
        realEstateListB.setMaximumSize(new Dimension(25, 25));
        realEstateListB.setMinimumSize(new Dimension(25, 25));
        realEstateListB.setPreferredSize(new Dimension(25, 25));
        realEstateListB.setEnabled(false);
        mainTB.add(realEstateListB);
        diaryB.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/sch_icon.png")));
        diaryB.setToolTipText("Agenda des r\351servations");
        diaryB.setBorder(null);
        diaryB.setMargin(new Insets(2, 2, 2, 2));
        diaryB.setMaximumSize(new Dimension(25, 25));
        diaryB.setMinimumSize(new Dimension(25, 25));
        diaryB.setPreferredSize(new Dimension(25, 25));
        diaryB.setEnabled(false);
        mainTB.add(diaryB);
        helpB.setIcon(new ImageIcon(getClass().getResource("/org/jpgolay/gui/images/help_icon.png")));
        helpB.setToolTipText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("help"));
        helpB.setBorder(null);
        helpB.setMargin(new Insets(2, 2, 2, 2));
        helpB.setMaximumSize(new Dimension(25, 25));
        helpB.setMinimumSize(new Dimension(25, 25));
        helpB.setPreferredSize(new Dimension(25, 25));
        mainTB.add(helpB);
        getContentPane().add(mainTB, "West");
        mainDP.setPreferredSize(new Dimension(800, 600));
        mainSP.setViewportView(mainDP);
        getContentPane().add(mainSP, "Center");
        file.setMnemonic('W');
        file.setText("WebImmo");
        openNew.setMnemonic('n');
        openNew.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("new_mi"));
        realEstate.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("realestate"));
        realEstate.setEnabled(false);
        openNew.add(realEstate);
        file.add(openNew);
        open.setMnemonic('o');
        open.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("open_mi"));
        realEstateMI.setAccelerator(KeyStroke.getKeyStroke(113, 0));
        realEstateMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("card"));
        realEstateMI.setEnabled(false);
        open.add(realEstateMI);
        realEstateList.setAccelerator(KeyStroke.getKeyStroke(114, 0));
        realEstateList.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("list"));
        realEstateList.setEnabled(false);
        open.add(realEstateList);
        file.add(open);
        file.add(jSeparator1);
        exit.setAccelerator(KeyStroke.getKeyStroke(123, 0));
        exit.setMnemonic('q');
        exit.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("exit"));
        file.add(exit);
        jMenuBar1.add(file);
        outsider.setMnemonic('T');
        outsider.setText("Tiers");
        groupMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("groupes"));
        groupMI.setEnabled(false);
        outsider.add(groupMI);
        agencyMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("agencie"));
        agencyMI.setEnabled(false);
        outsider.add(agencyMI);
        customerMI.setText("clients");
        customerMI.setEnabled(false);
        outsider.add(customerMI);
        salesPersonMI.setText("commerciaux");
        salesPersonMI.setEnabled(false);
        outsider.add(salesPersonMI);
        userMI.setAccelerator(KeyStroke.getKeyStroke(118, 0));
        userMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("users"));
        userMI.setEnabled(false);
        outsider.add(userMI);
        jMenuBar1.add(outsider);
        tools.setMnemonic('O');
        tools.setText("Options");
        guiM.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("lookandfeel"));
        glassRBMI.setSelected(true);
        glassRBMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("glass"));
        buttonGroup1.add(glassRBMI);
        guiM.add(glassRBMI);
        defaultRBMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("beach"));
        buttonGroup1.add(defaultRBMI);
        guiM.add(defaultRBMI);
        bedouinRBMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("grey"));
        buttonGroup1.add(bedouinRBMI);
        guiM.add(bedouinRBMI);
        acidRBMI.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("green"));
        buttonGroup1.add(acidRBMI);
        guiM.add(acidRBMI);
        metalRBMI.setText("m\351tal");
        buttonGroup1.add(metalRBMI);
        guiM.add(metalRBMI);
        tools.add(guiM);
        tools.add(getPreferencesMI());
        jMenuBar1.add(tools);
        info.setMnemonic('I');
        info.setText("?");
        help.setAccelerator(KeyStroke.getKeyStroke(112, 0));
        help.setMnemonic('a');
        help.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("help"));
        info.add(help);
        info.add(jSeparator3);
        about.setMnemonic('p');
        about.setText(ResourceBundle.getBundle("org/jpgolay/wi/wii").getString("about"));
        info.add(about);
        jMenuBar1.add(info);
        setJMenuBar(jMenuBar1);
        pack();
    }

    private JMenuItem getPreferencesMI() {
        if (preferencesMI == null) {
            preferencesMI = new JMenuItem();
            preferencesMI.setText("pr\351f\351rences");
        }
        return preferencesMI;
    }

    public JMenuItem getPreferences() {
        return getPreferencesMI();
    }

    public JButton getRealEstateB() {
        return realEstateB;
    }

    public JButton getDiaryB() {
        return diaryB;
    }

    public JButton getRealEstateListB() {
        return realEstateListB;
    }

    public JButton getHelpB() {
        return helpB;
    }

    public JMenuItem getExit() {
        return exit;
    }

    public JMenuItem getAbout() {
        return about;
    }

    public JMenuItem getHelp() {
        return help;
    }

    public JMenuItem getRealEstateList() {
        return realEstateList;
    }

    public JMenuItem getCustomer() {
        return customerMI;
    }

    public JMenuItem getSalesPerson() {
        return salesPersonMI;
    }

    public JMenuItem getRealEstate() {
        return realEstate;
    }

    public JMenuItem getRealEstateMI() {
        return realEstateMI;
    }

    public JMenuItem getUser() {
        return userMI;
    }

    public JMenuItem getAgency() {
        return agencyMI;
    }

    public JMenuItem getGroup() {
        return groupMI;
    }

    public JMenuItem getGlassRBMI() {
        return glassRBMI;
    }

    public JMenuItem getDefaultRBMI() {
        return defaultRBMI;
    }

    public JMenuItem getBedouinRBMI() {
        return bedouinRBMI;
    }

    public JMenuItem getAcidRBMI() {
        return acidRBMI;
    }

    public JMenuItem getMetalRBMI() {
        return metalRBMI;
    }

    public JDesktopPane getMainDP() {
        return mainDP;
    }

    public void setMainDP(JDesktopPane mainDP) {
        this.mainDP = mainDP;
    }

    public void setLookAndFeel(int type) {
        switch (type) {
            case 0: // '\0'
                glassRBMI.setSelected(true);
                break;

            case 1: // '\001'
                defaultRBMI.setSelected(true);
                break;

            case 2: // '\002'
                bedouinRBMI.setSelected(true);
                break;

            case 3: // '\003'
                acidRBMI.setSelected(true);
                break;

            case 4: // '\004'
                metalRBMI.setSelected(true);
                break;

            default:
                glassRBMI.setSelected(true);
                break;
        }
    }
    private JMenu tools;
    private JMenuItem about;
    private JMenuItem help;
    private JButton helpB;
    private JMenuItem exit;
    protected JMenuItem realEstate;
    protected JButton realEstateB;
    protected JMenuItem realEstateMI;
    private JMenu file;
    private JMenu info;
    private JMenuBar jMenuBar1;
    private JSeparator jSeparator1;
    private JSeparator jSeparator2;
    private JSeparator jSeparator3;
    protected JMenuItem realEstateList;
    protected JButton realEstateListB;
    protected JButton diaryB;
    protected JMenuItem customerMI;
    protected JMenuItem salesPersonMI;
    private JDesktopPane mainDP;
    private JToolBar mainTB;
    protected JMenuItem userMI;
    protected JMenuItem agencyMI;
    protected JMenuItem groupMI;
    private JMenu openNew;
    private JMenu open;
    private JMenu outsider;
    private JScrollPane mainSP;
    private ButtonGroup buttonGroup1;
    private JMenu guiM;
    private JRadioButtonMenuItem glassRBMI;
    private JRadioButtonMenuItem defaultRBMI;
    private JRadioButtonMenuItem bedouinRBMI;
    private JRadioButtonMenuItem acidRBMI;
    private JRadioButtonMenuItem metalRBMI;
    private JMenuItem preferencesMI;
    private Image imageIcon;
}
